// Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`,
// then press Enter. You can now see whitespace characters in your code.

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // Press Alt+Enter with your caret at the highlighted text to see how
        // IntelliJ IDEA suggests fixing it.
//        Scanner scanner = new Scanner(System.in); // 创建Scanner对象并传入标准输入流（键盘）作为参数
//
//        System.out.print("请输入内容："); // 提示用户输入信息
//        String input = scanner.nextLine();

        long i=1;
        long s=0;
        long startTime = System.currentTimeMillis();
        for (i=1;i<=10000000;i++){
            s+=i;
        }
        System.out.println(s);
        long endTime = System.currentTimeMillis();    //获取结束时间

        System.out.println("程序运行时间：" + (endTime - startTime) + "ms");    //输出程序运行时间






         i=1;
         s=0;
         startTime = System.currentTimeMillis();

            s=i*(i+1)/2;

        
        System.out.println(s);
         endTime = System.currentTimeMillis();    //获取结束时间

        System.out.println("程序运行时间：" + (endTime - startTime) + "ms");    //输出程序运行时间


    }
}